import { createRouter, createWebHashHistory } from "vue-router";
// createWebHistory,
const routes = [
    {
        path: '/',
        name: 'Home',
        component: () => import(/* webpackChunkName: "home" */ '@/views/home.vue'),
        meta: {
            title: '首页'
        }
    },
    {
        path: '/basic',
        name: 'Basic',
        component: () => import(/* webpackChunkName: "basic" */ '@/views/basic.vue'),
        meta: {
            title: '基础使用'
        }
    },
    {
        path: '/form',
        name: 'Form',
        component: () => import(/* webpackChunkName: "form" */ '@/views/form.vue'),
        meta: {
            title: '表单验证'
        }
    },
    {
        // path: '/route/:id', // params传参
        path: '/route', // query传参
        name: 'Route',
        component: () => import(/* webpackChunkName: "route" */ '@/views/route.vue'),
        meta: {
            title: '路由'
        }
    },
    {
        path: '/dynamicallyEditCss',
        name: 'DynamicallyEditCss',
        component: () => import(/* webpackChunkName: "dynamicallyEditCss" */ '@/views/dynamicallyEditCss.vue'),
        meta: {
            title: '动态修改css'
        }
    },
    {
        path: '/lang',
        name: 'Lang',
        component: () => import(/* webpackChunkName: "lang" */ '@/views/lang.vue'),
        meta: {
            title: '国际化'
        }
    },
    {
        path: '/:pathMatch(.*)*',
        name: 'NotFound',
        component: () => import(/* webpackChunkName: "notFound" */ '@/views/404.vue'),
        meta: {
            title: '404'
        }
    }
]
const router = createRouter({
    // history: createWebHistory(), // history模式
    history: createWebHashHistory(), // hash模式
    scrollBehavior: () => ({ y: 0 }),
    routes
})
router.afterEach((to, _from) => {
    document.title = to.meta.title || 'vite-demo'
})
export default router